#include <stdio.h>
#include <limits.h>



typedef struct data
{
    int sum;
    int L;
    int R;
}DATA;

DATA Csub(int A[],DATA a)
{
    int mid=(a.L+a.R)/2;
    int lsum=INT_MIN;
    int ltmp=0;
    int rtmp=0;
    int num=0;
    for(int i=mid;i>=a.L;i--)
    {
        num+=A[i];
        if(num>lsum)
        {
            lsum=num;
            ltmp=i;
        }
    }
    int rsum=INT_MIN;
    num=0;
    for(int j=mid+1;j<=a.R;j++)
    {
        num+=A[j];
        if(num>rsum)
        {
            rsum=num;
            rtmp=j;
        }
    }
    a.L=ltmp;
    a.R=rtmp;
    a.sum=lsum+rsum;
    return a;
}

DATA Maxsun(int A[],DATA a)
{
    if(a.L==a.R)
    {
        a.sum=A[a.L];
        return a;
    }
    else
    {
        int m=(a.L+a.R)/2;
        DATA left,right;
        left.L=a.L;
        left.R=m;
        right.L=m+1;
        right.R=a.R;
        DATA leftsum= Maxsun(A,left);
        DATA rightsum= Maxsun(A,right);
        DATA csum=Csub(A,a);

        if(leftsum.sum>=rightsum.sum&&leftsum.sum>=csum.sum)
        {
            left.L=a.L;
            right.L=m;
            return leftsum;
        }
        else
        {
            if(rightsum.sum>=leftsum.sum&&rightsum.sum>=csum.sum)
            {
                left.L=m+1;
                right.R=a.R;
                return rightsum;
            }
            else
                return csum;
        }

    }
}



int main(void) {
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    DATA s;
    s.L=0;
    s.R=n-1;
    DATA sum=Maxsun(a,s);
    printf("%d %d %d",sum.L,sum.R,sum.sum);

    return 0;
}
